import * as directoryApi from '@/api/hmmm/directorys'
import { list } from '@/api/hmmm/directorys'

const state = {
  directoryList: {}
}
const mutations = {
  SET_DIRECTORY_LIST: (state, newValue) => {
    newValue.data.items = newValue.data.items.map((item, i) => ({
      ...item,
      index: (newValue.data.page - 1) * newValue.data.pagesize + (i + 1)
    }))
    state.directoryList = newValue.data
  }
}
const actions = {
  async updateDirectoryList ({ commit }, params) {
    const res = await directoryApi.list(params)
    commit('SET_DIRECTORY_LIST', res)
  }
}
export default {
  namespaced: true,
  state,
  mutations,
  actions
}
